﻿//-----------------------------------------------------------------------
// <copyright file="LogTest.cs" company="FastNET Services">
//     Copyright (c) 2008-2009. All Rights Reserved.
// </copyright>
// <license>
//     GPLv2
// </license>
// <warranty>
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//     BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//     DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </warranty>
//-----------------------------------------------------------------------
#region Usings
using System;
using FastNET.CleanAct.Common.Repository.Interfaces.DataInterfaces.General;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Log = FastNET.CleanAct.Client.ManagerEngineData.Entities.Log;
#endregion

namespace FastNET.CleanAct.Testing.Client.ManagerEngineData.Entities
{
    /// <summary>
    /// Unit Tests for LogTest
    /// </summary>
    [TestClass]
    public class LogTest
    {
        /// <summary>
        /// Gets or sets the test context which provides
        /// information about and functionality for the current test run.
        /// </summary>
        public TestContext TestContext { get; set; }

        #region Message Validation

        /// <summary>
        /// Test for Message being Null
        /// </summary>
        [TestMethod]
        public void Message_Null()
        {
            new Log { Message = null };
        }

        /// <summary>
        /// Test for Message being Too Long
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void Message_TooLong()
        {
            new Log { Message = string.Empty.PadRight(4001, 'A') };
        }

        /// <summary>
        /// Test for Message being successful
        /// </summary>
        [TestMethod]
        public void Message_Success()
        {
            ILogEntryData data = new Log { Message = "TestName" };
            Assert.AreEqual("TestName", data.Message, "Mismatched Data");
        }

        /// <summary>
        /// Test for Message being defaulted
        /// </summary>
        [TestMethod]
        public void Message_Default()
        {
            ILogEntryData data = new Log();
            Assert.AreEqual(null, data.Message, "Mismatched Data");
        }

        #endregion

        #region Categories Validation

        /// <summary>
        /// Test for Categories being Null
        /// </summary>
        [TestMethod]
        public void Categories_Null()
        {
            new Log { Categories = null };
        }

        /// <summary>
        /// Test for Categories being Too Long
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void Categories_TooLong()
        {
            new Log { Categories = string.Empty.PadRight(4001, 'A') };
        }

        /// <summary>
        /// Test for Categories being successful
        /// </summary>
        [TestMethod]
        public void Categories_Success()
        {
            ILogEntryData data = new Log { Categories = "TestName" };
            Assert.AreEqual("TestName", data.Categories, "Mismatched Data");
        }

        /// <summary>
        /// Test for Categories being defaulted
        /// </summary>
        [TestMethod]
        public void Categories_Default()
        {
            ILogEntryData data = new Log();
            Assert.AreEqual(null, data.Categories, "Mismatched Data");
        }

        #endregion

        #region Priority Validation

        /// <summary>
        /// Test for Priority being successful
        /// </summary>
        [TestMethod]
        public void Priority_Success()
        {
            ILogEntryData data = new Log { Priority = 500 };
            Assert.AreEqual(500, data.Priority, "Mismatched Data");
        }

        /// <summary>
        /// Test for Priority being defaulted
        /// </summary>
        [TestMethod]
        public void Priority_Default()
        {
            ILogEntryData data = new Log();
            Assert.AreEqual(0, data.Priority, "Mismatched Data");
        }

        #endregion

        #region EventID Validation

        /// <summary>
        /// Test for EventID being successful
        /// </summary>
        [TestMethod]
        public void EventID_Success()
        {
            ILogEntryData data = new Log { EventID = 500 };
            Assert.AreEqual(500, data.EventID, "Mismatched Data");
        }

        /// <summary>
        /// Test for EventID being defaulted
        /// </summary>
        [TestMethod]
        public void EventID_Default()
        {
            ILogEntryData data = new Log();
            Assert.AreEqual(0, data.EventID, "Mismatched Data");
        }

        #endregion

        #region Severity Validation

        /// <summary>
        /// Test for Severity being Null
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Severity_Null()
        {
            new Log { Severity = null };
        }

        /// <summary>
        /// Test for Severity being Too Long
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void Severity_TooLong()
        {
            new Log { Severity = string.Empty.PadRight(101, 'A') };
        }

        /// <summary>
        /// Test for Severity being successful
        /// </summary>
        [TestMethod]
        public void Severity_Success()
        {
            ILogEntryData data = new Log { Severity = "TestName" };
            Assert.AreEqual("TestName", data.Severity, "Mismatched Data");
        }

        /// <summary>
        /// Test for Severity being defaulted
        /// </summary>
        [TestMethod]
        public void Severity_Default()
        {
            ILogEntryData data = new Log();
            Assert.AreEqual(null, data.Severity, "Mismatched Data");
        }

        #endregion

        #region Title Validation

        /// <summary>
        /// Test for Title being Null
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Title_Null()
        {
            new Log { Title = null };
        }

        /// <summary>
        /// Test for Title being Too Long
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void Title_TooLong()
        {
            new Log { Title = string.Empty.PadRight(201, 'A') };
        }

        /// <summary>
        /// Test for Title being successful
        /// </summary>
        [TestMethod]
        public void Title_Success()
        {
            ILogEntryData data = new Log { Title = "TestName" };
            Assert.AreEqual("TestName", data.Title, "Mismatched Data");
        }

        /// <summary>
        /// Test for Title being defaulted
        /// </summary>
        [TestMethod]
        public void Title_Default()
        {
            ILogEntryData data = new Log();
            Assert.AreEqual(null, data.Title, "Mismatched Data");
        }

        #endregion

        #region TimeStamp Validation

        /// <summary>
        /// Test for TimeStamp being successful
        /// </summary>
        [TestMethod]
        public void TimeStamp_Success()
        {
            DateTime value = DateTime.UtcNow;
            ILogEntryData data = new Log { TimeStamp = value };
            Assert.AreEqual(value, data.TimeStamp, "Mismatched Data");
        }

        /// <summary>
        /// Test for TimeStamp being defaulted
        /// </summary>
        [TestMethod]
        public void TimeStamp_Default()
        {
            ILogEntryData data = new Log();
            Assert.AreEqual(DateTime.MinValue, data.TimeStamp, "Mismatched Data");
        }

        #endregion

        #region MachineName Validation

        /// <summary>
        /// Test for MachineName being Null
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void MachineName_Null()
        {
            new Log { MachineName = null };
        }

        /// <summary>
        /// Test for MachineName being Too Long
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void MachineName_TooLong()
        {
            new Log { MachineName = string.Empty.PadRight(16, 'A') };
        }

        /// <summary>
        /// Test for MachineName being successful
        /// </summary>
        [TestMethod]
        public void MachineName_Success()
        {
            ILogEntryData data = new Log { MachineName = "TestName" };
            Assert.AreEqual("TestName", data.MachineName, "Mismatched Data");
        }

        /// <summary>
        /// Test for MachineName being defaulted
        /// </summary>
        [TestMethod]
        public void MachineName_Default()
        {
            ILogEntryData data = new Log();
            Assert.AreEqual(null, data.MachineName, "Mismatched Data");
        }

        #endregion

        #region AppDomainName Validation

        /// <summary>
        /// Test for AppDomainName being Null
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void AppDomainName_Null()
        {
            new Log { AppDomainName = null };
        }

        /// <summary>
        /// Test for AppDomainName being Too Long
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void AppDomainName_TooLong()
        {
            new Log { AppDomainName = string.Empty.PadRight(1001, 'A') };
        }

        /// <summary>
        /// Test for AppDomainName being successful
        /// </summary>
        [TestMethod]
        public void AppDomainName_Success()
        {
            ILogEntryData data = new Log { AppDomainName = "TestName" };
            Assert.AreEqual("TestName", data.AppDomainName, "Mismatched Data");
        }

        /// <summary>
        /// Test for AppDomainName being defaulted
        /// </summary>
        [TestMethod]
        public void AppDomainName_Default()
        {
            ILogEntryData data = new Log();
            Assert.AreEqual(null, data.AppDomainName, "Mismatched Data");
        }

        #endregion

        #region ProcessID Validation

        /// <summary>
        /// Test for ProcessID being successful
        /// </summary>
        [TestMethod]
        public void ProcessID_Success()
        {
            ILogEntryData data = new Log { ProcessId = 500 };
            Assert.AreEqual(500, data.ProcessId, "Mismatched Data");
        }

        /// <summary>
        /// Test for ProcessID being defaulted
        /// </summary>
        [TestMethod]
        public void ProcessID_Default()
        {
            ILogEntryData data = new Log();
            Assert.AreEqual(0, data.ProcessId, "Mismatched Data");
        }

        #endregion

        #region ProcessName Validation

        /// <summary>
        /// Test for ProcessName being Null
        /// </summary>
        [TestMethod]
        public void ProcessName_Null()
        {
            new Log { ProcessName = null };
        }

        /// <summary>
        /// Test for ProcessName being Too Long
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void ProcessName_TooLong()
        {
            new Log { ProcessName = string.Empty.PadRight(1001, 'A') };
        }

        /// <summary>
        /// Test for ProcessName being successful
        /// </summary>
        [TestMethod]
        public void ProcessName_Success()
        {
            ILogEntryData data = new Log { ProcessName = "TestName" };
            Assert.AreEqual("TestName", data.ProcessName, "Mismatched Data");
        }

        /// <summary>
        /// Test for ProcessName being defaulted
        /// </summary>
        [TestMethod]
        public void ProcessName_Default()
        {
            ILogEntryData data = new Log();
            Assert.AreEqual(null, data.ProcessName, "Mismatched Data");
        }

        #endregion

        #region ThreadName Validation

        /// <summary>
        /// Test for ThreadName being Null
        /// </summary>
        [TestMethod]
        public void ThreadName_Null()
        {
            new Log { ThreadName = null };
        }

        /// <summary>
        /// Test for ThreadName being Too Long
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void ThreadName_TooLong()
        {
            new Log { ThreadName = string.Empty.PadRight(1001, 'A') };
        }

        /// <summary>
        /// Test for ThreadName being successful
        /// </summary>
        [TestMethod]
        public void ThreadName_Success()
        {
            ILogEntryData data = new Log { ThreadName = "TestName" };
            Assert.AreEqual("TestName", data.ThreadName, "Mismatched Data");
        }

        /// <summary>
        /// Test for ThreadName being defaulted
        /// </summary>
        [TestMethod]
        public void ThreadName_Default()
        {
            ILogEntryData data = new Log();
            Assert.AreEqual(null, data.ThreadName, "Mismatched Data");
        }

        #endregion

        #region ThreadID Validation

        /// <summary>
        /// Test for ThreadID being Null
        /// </summary>
        [TestMethod]
        public void ThreadID_Null()
        {
            new Log { ThreadId = null };
        }

        /// <summary>
        /// Test for ThreadID being successful
        /// </summary>
        [TestMethod]
        public void ThreadID_Success()
        {
            ILogEntryData data = new Log { ThreadId = 500 };
            Assert.AreEqual(500, data.ThreadId, "Mismatched Data");
        }

        /// <summary>
        /// Test for ThreadID being defaulted
        /// </summary>
        [TestMethod]
        public void ThreadID_Default()
        {
            ILogEntryData data = new Log();
            Assert.AreEqual(null, data.ThreadId, "Mismatched Data");
        }

        #endregion

        #region ActivityID Validation

        /// <summary>
        /// Test for ActivityID being Null
        /// </summary>
        [TestMethod]
        public void ActivityID_Null()
        {
            new Log { ActivityId = null };
        }

        /// <summary>
        /// Test for ActivityID being successful
        /// </summary>
        [TestMethod]
        public void ActivityID_Success()
        {
            Guid value = Guid.NewGuid();
            ILogEntryData data = new Log { ActivityId = value };
            Assert.AreEqual(value, data.ActivityId, "Mismatched Data");
        }

        /// <summary>
        /// Test for ActivityID being defaulted
        /// </summary>
        [TestMethod]
        public void ActivityID_Default()
        {
            ILogEntryData data = new Log();
            Assert.AreEqual(null, data.ActivityId, "Mismatched Data");
        }

        #endregion

        #region RelatedActivityID Validation

        /// <summary>
        /// Test for RelatedActivityID being Null
        /// </summary>
        [TestMethod]
        public void RelatedActivityID_Null()
        {
            new Log { RelatedActivityId = null };
        }

        /// <summary>
        /// Test for RelatedActivityID being successful
        /// </summary>
        [TestMethod]
        public void RelatedActivityID_Success()
        {
            Guid value = Guid.NewGuid();
            ILogEntryData data = new Log { RelatedActivityId = value };
            Assert.AreEqual(value, data.RelatedActivityId, "Mismatched Data");
        }

        /// <summary>
        /// Test for RelatedActivityID being defaulted
        /// </summary>
        [TestMethod]
        public void RelatedActivityID_Default()
        {
            ILogEntryData data = new Log();
            Assert.AreEqual(null, data.RelatedActivityId, "Mismatched Data");
        }

        #endregion
    }
}
